package com.erhirent.view;

import java.util.List;

import com.erhairent.tools.InputTools;
import com.erhirent.bean.Car;
import com.erhirent.bean.Type;

public class TypeView extends View {

	@Override
	public View showView() {
		boolean isconti = true;

		List<Type> list1 = mcar.querytype();
		if (list1.size() != 0) {
			System.out.println("---------------------------");
			System.err.println("类型ID\t" + "类型名称\t");
			for (Type type : list1) {
				System.out.print(type.gettypeId() + "\t");
				System.out.println(type.gettypeName() + "\t");
			}
			System.out.println("---------------------------");

			System.out.println("输入你想要查询的汽车类型编号:");
			for (; isconti;) {
				int n = InputTools.nextInt();

				List<Car> list2 = mcar.typequery(n);
				if (list2.size() != 0) {
					System.out.println("--------------------------------");
					System.out.println("汽车编号\t" + "汽车名称\t" + "备注\t" + "品牌\t" + "类型\t" + "单价\t" + "是否可租");
					for (Car car : list2) {
						System.out.print(car.getcarId() + "\t");
						System.out.print(car.getcarName() + "\t");
						System.out.print(car.getcarRemark() + "\t");
						System.out.print(car.getbrandName() + "\t");
						System.out.print(car.gettypeName() + "\t");
						System.out.print(car.getcarPrice() + "/天\t");
						System.out.println(car.getcarIsrent() + "\t");

					}
					System.out.println("--------------------------------");

					isconti = false;

				} else {
					System.out.println("没有该类型的车,重新输入");
					continue;
				}
			}

		} else {
			System.out.println("获取类型失败");
			return mView;
		}

		return mView;
	}

}
